import tkinter

root = tkinter.Tk(className="管理")

label = tkinter.Label(text="管理")
label.pack()

button = tkinter.Button(text="按钮", command=lambda: print("点击按钮"))
button.pack()

main_menu = tkinter.Menu(root)

menu1 = tkinter.Menu(main_menu, tearoff=False)
menu1.add_command(label="矩形", command=lambda: print("点击了矩形"))
menu1.add_command(label="圆形", command=lambda: print("点击了圆形"))
menu1.add_command(label="直线", command=lambda: print("点击了直线"))

main_menu.add_cascade(menu=menu1, label="图形")

menu2 = tkinter.Menu(main_menu, tearoff=False)
menu2.add_command(label="绿油油", command=lambda: print("点击了绿油油"))
main_menu.add_cascade(menu=menu2, label="颜色")

root.config(menu=main_menu)

root.mainloop()



# import tkinter
# from tkinter import messagebox
#
# root = tkinter.Tk(className="探索")
# main_menu = tkinter.Menu(root)
#
# menu1=tkinter.Menu(main_menu,tearoff=False)
# menu1.add_command(label="圆",command=lambda :print("111"))
# menu1.add_command(label="矩形",command=lambda :print("111"))
#
# def exit():
#     r=messagebox.askyesno(title="退出",message="是否退出")
#     if r:
#         root.destroy()
#
# menu1.add_command(label="退出",command=exit)
# main_menu.add_cascade(menu=menu1,label="图形")
#
# root.config(menu=main_menu)
#
# canvas=tkinter.Canvas(root,width=600,height=400)
#
#
# canvas.bind("<Button-1>",func=lambda n:print(f"X={n.x},Y={n.y}"))
#
# canvas.bind("<ButtonRelease-1>",lambda e:print(f"X={e.x},Y={e.y}"))
# canvas.create_line(100,100,200,300)
# canvas.create_oval(100,100,200,300)
# canvas.create_rectangle(100,100,200,300)
#
# canvas.pack()
#
#
# root.mainloop()


